package com.thd.springboottest.shironostate.filter;

import com.thd.springboottest.shironostate.token.JwtToken;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
import org.apache.shiro.web.util.WebUtils;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.util.stream.Stream;

/**
 * 自定义带有参数的Filter
 *
 * 例如 shiroConfig中
 *  map.put("/params","params[1,2,3]");
 *  对应的[1,2,3]的获取
 */
public class MyParamsFilter extends FormAuthenticationFilter {

    public MyParamsFilter() {
        super();
    }

    // 测试地址：http://localhost:8899/thd/params
    @Override
    public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue){
        System.out.println(" MyParamsFilter isAccessAllowed ...");
        System.out.println(" Filter Params is :");
        String[] filterParams = (String[])mappedValue;
        Stream.of(filterParams).forEach(System.out::println);
        return true;
    }



}
